|
1
|
|
|
/* |
|
2
|
|
|
* CMS Pico - Integration of Pico within your files to create websites. |
|
3
|
|
|
* |
|
4
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
|
5
|
|
|
* later. See the COPYING file. |
|
6
|
|
|
* |
|
7
|
|
|
* @author Maxence Lange <[email protected]> |
|
8
|
|
|
* @copyright 2017 |
|
9
|
|
|
* @license GNU AGPL version 3 or any later version |
|
10
|
|
|
* |
|
11
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
12
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
13
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
14
|
|
|
* License, or (at your option) any later version. |
|
15
|
|
|
* |
|
16
|
|
|
* This program is distributed in the hope that it will be useful, |
|
17
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19
|
|
|
* GNU Affero General Public License for more details. |
|
20
|
|
|
* |
|
21
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
22
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
23
|
|
|
* |
|
24
|
|
|
*/ |
|
25
|
|
|
|
|
26
|
|
|
/** global: OC */ |
|
27
|
|
|
/** global: OCA */ |
|
28
|
|
|
/** global: pico_define */ |
|
29
|
|
|
/** global: pico_elements */ |
|
30
|
|
|
/** global: pico_nav */ |
|
31
|
|
|
|
|
32
|
|
|
var pico_result = { |
|
33
|
|
|
|
|
34
|
|
|
displayWebsites: function (list) { |
|
35
|
|
|
|
|
36
|
|
|
pico_elements.cms_pico_list_websites.emptyTable(); |
|
37
|
|
|
|
|
38
|
|
|
for (var i = 0; i < list.length; i++) { |
|
39
|
|
|
var tmpl = pico_nav.generateTmplWebsite(list[i]); |
|
40
|
|
|
pico_elements.cms_pico_list_websites.append(tmpl); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
pico_elements.cms_pico_list_websites.children('tr').each(function () { |
|
44
|
|
|
pico_result.interactionWebsitesDelete($(this)); |
|
45
|
|
|
pico_result.displayWebsitesLink($(this)); |
|
46
|
|
|
pico_result.displayWebsitesPath($(this)); |
|
47
|
|
|
pico_result.displayWebsitesPrivate($(this)); |
|
48
|
|
|
}); |
|
49
|
|
|
|
|
50
|
|
|
}, |
|
51
|
|
|
|
|
52
|
|
|
|
|
53
|
|
|
displayWebsitesLink: function (div) { |
|
54
|
|
|
var url = div.attr('data-address'); |
|
55
|
|
|
div.find('TD.link').css('cursor', 'pointer').on('click', function () { |
|
56
|
|
|
window.open(url); |
|
57
|
|
|
}); |
|
58
|
|
|
}, |
|
59
|
|
|
|
|
60
|
|
|
|
|
61
|
|
|
displayWebsitesPath: function (div) { |
|
62
|
|
|
var url = pico_define.nchost + pico_define.index + OC.appswebroots.files + '/?dir=' + |
|
63
|
|
|
div.attr('data-path'); |
|
64
|
|
|
div.find('TD.path').css('cursor', 'pointer').on('click', function () { |
|
65
|
|
|
window.open(url); |
|
66
|
|
|
}); |
|
67
|
|
|
}, |
|
68
|
|
|
|
|
69
|
|
|
|
|
70
|
|
|
displayWebsitesPrivate: function (div) { |
|
71
|
|
|
div.find('INPUT.private').prop('checked', div.attr('data-private') === '1').on( |
|
72
|
|
|
'change', function () { |
|
73
|
|
|
pico_nav.updateWebsiteOption(div.attr('data-id'), 'private', |
|
74
|
|
|
($(this).is(':checked')) ? '1' : '0'); |
|
75
|
|
|
}); |
|
76
|
|
|
}, |
|
77
|
|
|
|
|
78
|
|
|
|
|
79
|
|
|
interactionWebsitesDelete: function (div) { |
|
80
|
|
|
div.find('BUTTON.icon-delete').on('click', function () { |
|
81
|
|
|
pico_nav.deleteWebsite(div.attr('data-id'), div.attr('data-name')); |
|
82
|
|
|
}); |
|
83
|
|
|
}, |
|
84
|
|
|
|
|
85
|
|
|
|
|
86
|
|
|
createNewWebsiteResult: function (result) { |
|
87
|
|
|
|
|
88
|
|
|
if (result.status === 1) { |
|
89
|
|
|
OCA.notification.onSuccess('Website created'); |
|
90
|
|
|
pico_result.displayWebsites(result.websites); |
|
91
|
|
|
pico_nav.resetFields(); |
|
92
|
|
|
return; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
OCA.notification.onFail( |
|
96
|
|
|
t('cms_pico', "It was not possible to create your website {name}", |
|
97
|
|
|
{name: result.name}) + |
|
98
|
|
|
': ' + ((result.error) ? result.error : t('circles', 'no error message'))); |
|
99
|
|
|
}, |
|
100
|
|
|
|
|
101
|
|
|
|
|
102
|
|
|
deleteWebsiteResult: function (result) { |
|
103
|
|
|
|
|
104
|
|
|
if (result.status === 1) { |
|
105
|
|
|
OCA.notification.onSuccess('Website removed'); |
|
106
|
|
|
pico_result.displayWebsites(result.websites); |
|
107
|
|
|
return; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
OCA.notification.onFail( |
|
111
|
|
|
t('cms_pico', "It was not possible to remove the website {name}", |
|
112
|
|
|
{name: result.name}) + |
|
113
|
|
|
': ' + ((result.error) ? result.error : t('circles', 'no error message'))); |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
} |
|
117
|
|
|
; |